/**
 * Klasse   DebitCard tbv. project KantineSimulatie om betalingen met pinpas te verrichten
 * @author  (Stephan Veenstra, Michel Jansma) 
 * @version (2012.10.15)
 */
public class DebitCard extends PaymentWay {
    
    //Instantie variabelen definiëren van het type double
    private double limit;

    /**
     * @method DebitCard
     * @params null
     * @info   Constructor DebitCard klasse
     * @return null
     */
    public DebitCard(double balance, double limit) {
       //Initialiseren instantie variabele limit
       this.setCreditLimit(limit);
       //Initialiseren instantie variabele balance
       super.setBalance(balance);
    }
    
    /**
     * SETTER METHODES
     */
    
    /**
     * @method setCreditLimit
     * @params <double> limit
     * @info   Instantie variabele limit
     * @return false
     */
    public void setCreditLimit(double limit) {
        this.limit = limit;
    }
    
    /**
     * GETTER METHODES
     */
    
    /**
     * @method getCreditLimit
     * @params null
     * @info   Retourneer instantie variabele limit
     * @return <double> limit
     */
    public double getCreditLimit() {
        return this.limit;
    }
    
    /**
     * @method handlePayment
     * @params <double> toPay
     * @info   Handel betaling af
     * @return <boolean> isPayed
     */
    @Override
    public boolean handlePayment(double toPay) {
        double balance = this.getBalance() - toPay;
        System.out.println(balance);
        if(balance > this.getCreditLimit()) {
            //Betaling succesvol afgerond, update balans
            this.setBalance(balance);
            System.out.println("!_TMP betaling succesvol afgerond");
            return true;
        }
        System.out.println("Onvoldoende saldo, betaal op een andere a.u.b.");
        return false;
        
    }

}
